<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>自助打印后台系统</title>
	<meta http-equiv="x-ua-compatible" content="IE=10,9,8">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="自助打印" />
    <link rel="apple-touch-icon-precomposed" href="static/images/i/edu.png">

    <link rel="stylesheet" href="static/js/Layui-v2.5.5/layui/css/layui.css" media="all" />

    <script src="static/js/jquery-2.1.0.min.js"></script>
    <script src="static/js/date.format.js"></script>

    <link rel="stylesheet" href="static/js/Layui-formSelects-master/dist/formSelects-v4.css" media="all" />

    <style type="text/css">
        * {
            box-sizing:content-box;
        }
        /*如果 layui 数据表格列宽自适应出现横向滚动条的解决方案*/
        body {
            overflow-y: scroll;
        }
        /*解决有水平滚动条问题*/
        .childrenBody {
            padding: 10px;
        }
    </style>
</head>
<body class="childrenBody">
<form id="infoListForm" class="layui-form layui-row layui-col-space10" >
    <div class="layui-col-md9 layui-col-xs12">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
             <ul class="layui-tab-title">
                <li class="layui-this">用户信息</li>
            </ul> 

            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-form layui-tab-item layui-show">
                    <input type="hidden" class="layui-input" name="id" value="${adminUser.id}">

                  
                    <div class="layui-row layui-col-space10">
                        <div class="layui-inline layui-col-md5">
                            <label class="layui-form-label">姓名<font color="red">*</font></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input"  name="name" value="${adminUser.name}" lay-verify="required" placeholder="请输入身份证号"/>
                            </div>
                        </div>
                        
                        <div class="layui-inline layui-col-md5">
                            <label class="layui-form-label">联系电话<font color="red">*</font></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="phone" value="${adminUser.phone}" placeholder="请输入电话" />
                         	</div>
                        </div>

                      <%--   <div class="layui-inline layui-col-md5">
                            <label class="layui-form-label">科室名称</font></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="deptName"  value="${adminUser.deptName }" placeholder="请输入科室名称" />
                            </div>
                        </div> --%>
                    </div>
                    
                     <div class="layui-row layui-col-space10">
                        <div class="layui-inline layui-col-md5">
                            <label class="layui-form-label">身份证号<font color="red">*</font></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="idCard"   value="${adminUser.idCard}" lay-verify="required" placeholder="请输入身份证号"/>
                            </div>
                        </div>

                        <div class="layui-inline layui-col-md5">
                            <label class="layui-form-label">用户名<font color="red">*</font></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="userName"  value="${adminUser.userName }" placeholder="请输入用户名" />
                            </div>
                        </div>
                    </div>
                    
                      <div class="layui-row layui-col-space10">
                       <c:if test="${empty adminUser}">
                        <div class="layui-inline layui-col-md5">
                            <label class="layui-form-label">密码<font color="red">*</font></label>
                            <div class="layui-input-block">
                                <input type="text" class="layui-input" name="password"  value="${adminUser.password}" lay-verify="required" placeholder="请输入密码" />
                            </div>
                        </div>
                        </c:if>
                        </div>
                        
                      

                      
                  
                    

                


                </div>
                </div>


             
             
        </div>
    </div>
    <div class="layui-col-md3 layui-col-xs12">
        <blockquote class="layui-elem-quote title magt10"><i class="layui-icon">&#xe609;</i> 保存</blockquote>
        <div class="border">
            <br/>
            <hr class="layui-bg-gray" />
            <div class="layui-right">
                <c:if test="${view eq 1 }">
                    <a class="layui-btn layui-btn-sm" onclick="closeBasic();"><i class="layui-icon">&#x1006;</i>返回</a>
                </c:if>
                <c:if test="${empty view }">
                    <a class="layui-btn layui-btn-sm" lay-filter="addBasic" lay-submit><i class="layui-icon">&#xe609;</i>保存</a>
                </c:if>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="static/js/Layui-v2.5.5/layui/layui.js"></script>
<script type="text/javascript">
    //全局定义一次, 加载formSelects
    layui.config({
        base: 'static/js/Layui-formSelects-master/dist/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v4'
    });

    layui.use(['form','layer','layedit','laydate','upload','element', 'table', 'formSelects'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            laypage = layui.laypage,
            upload = layui.upload,
            layedit = layui.layedit,
            laydate = layui.laydate,
            element = layui.element;
        table = layui.table;
        formSelects = layui.formSelects;
        $ = layui.jquery;
        //时间格式化
     /*   laydate.render({
            elem: '#opsDate', //指定元素
            type: 'datetime'
        });*/

        form.verify({
           
        });


        form.on("submit(addBasic)",function(data){

            //弹出loading
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});

            var params = $("#infoListForm").serializeArray();
            
        
            $.ajax({
                url: "${pageContext.request.contextPath}/admin/saveOrUpdateAdminUser",
                //dataType: "json",
                type: "POST",
              //  contentType: 'application/json;charset=UTF-8',
                data:params ,
                success:function(result){

                   if(result!=null){
                       var data = $.parseJSON(result);
                       if(data.code == "1"){
                           setTimeout(function(){
                               top.layer.close(index);
                               top.layer.msg("保存成功！");
                               layer.closeAll("iframe");
                               //刷新父页面
                               parent.location.reload();
                           },500);
                       }else{
                           top.layer.msg("保存失败！");
                           return false;
                       }

                   }


                }
            });
        });

    });

    function closeBasic(){
        var index = top.layer.msg('正在关闭，请稍候',{icon: 16,time:false,shade:0.8});

        setTimeout(function(){
            top.layer.close(index);
            layer.closeAll("iframe");
            //刷新父页面
            parent.location.reload();
        },500);

        return false;
    }


    //时间戳转日期
    function dateFormat(timeStamp) {
        var date = new Date(timeStamp);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? '0' + m : m;
        var d = date.getDate();
        d = d < 10 ? ("0" + d) : d;
        var h = date.getHours();
        h = h < 10 ? ("0" + h) : h;
        var M = date.getMinutes();
        M = M < 10 ? ("0" + M) : M;
        var S = date.getSeconds();
        S = S < 10 ? ("0" + S) : S;
        var str = y + "-" + m + "-" + d + " " + h + ":" + M + ":" + S;
        return str;
    }

    function validataNum(param,length){
        var reg = new RegExp("^[0-9]*$");
        if(!reg.test(param)){
            return false;
        }
        if(param.length>length){
            return false;
        }

        return true;
    }

</script>
</body>
</html>
